package com.appli.ImpossibleQuestSeason1;

import utils.DrawView;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class ImpossibleQuestSeason1Episode3 extends Activity implements OnClickListener {
	
	DrawView drawView;
	int X,Y;
	boolean firstStepActivated, secondStepActivated, thirdStepActivated = false;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.episode3);
        ((Button)findViewById(R.id.button1)).setOnClickListener(this);
        ((Button)findViewById(R.id.button2)).setOnClickListener(this);
        ((Button)findViewById(R.id.button3)).setOnClickListener(this);
        ((Button)findViewById(R.id.button4)).setOnClickListener(this);
        ((Button)findViewById(R.id.button5)).setVisibility(View.GONE);
    }

	@Override
	public void onClick(View v) {
		switch (v.getId()){
			case R.id.button1:
				X= ((DrawView)findViewById(R.id.appliImpossibleQuestSeasonDrawView1)).buttonPlusX();
			break;
			case R.id.button2:
				X = ((DrawView)findViewById(R.id.appliImpossibleQuestSeasonDrawView1)).buttonMoinsX();
			break;
			case R.id.button3:
				Y = ((DrawView)findViewById(R.id.appliImpossibleQuestSeasonDrawView1)).buttonPlusY();
			break;
			case R.id.button4:
				Y = ((DrawView)findViewById(R.id.appliImpossibleQuestSeasonDrawView1)).buttonMoinsY();
			break;
			case R.id.ButtonAnswerEpisode5:
			break;
		}
		
		testLaserPosition();
	}

	private void testLaserPosition() {
		if (X == 26 && Y == 1 && !firstStepActivated){
			Toast.makeText(this, "North-East ennemies ...", Toast.LENGTH_LONG).show();
			firstStepActivated = true;
		}
		
		if (X == 1 && Y == 9 && firstStepActivated && !secondStepActivated){
			Toast.makeText(this, "... will attack South-West basements ...", Toast.LENGTH_LONG).show();
			secondStepActivated = true;
		}
		
		if (X == 13 && Y == 6 && firstStepActivated && secondStepActivated && !thirdStepActivated){
			Toast.makeText(this, "... We have to place an ambush", Toast.LENGTH_LONG).show();
			thirdStepActivated = true;
		}
		
		if (thirdStepActivated){
			Toast.makeText(this, "Message send !", Toast.LENGTH_LONG).show();
			((Button)findViewById(R.id.button5)).setVisibility(View.VISIBLE);
			((Button)findViewById(R.id.button1)).setVisibility(View.GONE);
			((Button)findViewById(R.id.button2)).setVisibility(View.GONE);
			((Button)findViewById(R.id.button3)).setVisibility(View.GONE);
			((Button)findViewById(R.id.button4)).setVisibility(View.GONE);
		}
	}
}